## Table A12: Effects of Changes in Differential Demand by Year on Wait Times

## install.packages(c("tidyverse", "fixest"))
## library(tidyverse)

## SET WORKING DIRECTORY HERE
## setwd()

## Loading data
## load("demand_yearly.RData")

## Column 1
race_wait_demand <- feols(log_mean_wait ~ non_white_demand |
                            city_service + open_year, 
                          data = demand_yearly, 
                          weights = demand_yearly$tot_calls)

## Column 2
race_wait_need <- feols(log_mean_wait ~ non_white_need |
                          city_service + open_year, 
                        data = demand_yearly, 
                        weights = demand_yearly$tot_calls)

## Column 3
income_wait_demand <- feols(log_mean_wait ~ poor_demand |
                              city_service + open_year, 
                            data = demand_yearly, 
                            weights = demand_yearly$tot_calls)

## Column 4
income_wait_need <- feols(log_mean_wait ~ poor_need |
                            city_service + open_year, 
                          data = demand_yearly, 
                          weights = demand_yearly$tot_calls)

## Column 5
race_expected_demand <- feols(log_mean_expected ~ non_white_demand |
                                city_service + open_year, 
                              data = demand_yearly, 
                              weights = demand_yearly$tot_calls)

## Column 6
race_expected_need <- feols(log_mean_expected ~ non_white_need |
                              city_service + open_year, 
                            data = demand_yearly, 
                            weights = demand_yearly$tot_calls)

## Column 7
income_expected_demand <- feols(log_mean_expected ~ poor_demand |
                                  city_service + open_year, 
                                data = demand_yearly, 
                                weights = demand_yearly$tot_calls)

## Column 8
income_expected_need <- feols(log_mean_expected ~ poor_need |
                                city_service + open_year, 
                              data = demand_yearly, 
                              weights = demand_yearly$tot_calls)

TableA12 = etable(race_wait_demand, race_wait_need,
                  income_wait_demand, income_wait_need,
                  race_expected_demand, race_expected_need,
                  income_expected_demand, income_expected_need,
                  signifCode = c("+" = 0.10, "*" = 0.05, "**" = 0.01, "***" = 0.001),
                  digits = 3, digits.stats = 3, fitstat = c("n","r2"))